package com.ruoyi.web.controller.job;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.JobSpecialConfig;
import com.ruoyi.system.service.AppSignLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("app/sign/limit")
public class AppSignLimitController {

    @Autowired
    private AppSignLimitService appSignLimitService;

    @PostMapping
    public AjaxResult limit(@RequestBody JobSpecialConfig jobSpecialConfig) {
        if (null == jobSpecialConfig ||
                StringUtils.isEmpty(jobSpecialConfig.getJobType()) ||
                StringUtils.isEmpty(jobSpecialConfig.getLinkName())) {
            return AjaxResult.error("参数异常");
        }

        boolean limit = appSignLimitService.signLimit(jobSpecialConfig);

        if (!limit) {
            return AjaxResult.error("无权限");
        }

        return AjaxResult.success();
    }

}
